package com.sline.generic;

import com.sline.bean.Person;
import com.sline.bean.Tool;

import java.util.ArrayList;
import java.util.Iterator;

public class Demo1_Generic {
    public static void main (String[] args) {
        // demo1();

        // demo2();

        Tool<String> tool = new Tool<>();
        tool.show("abc ");
    }

    private static void demo2() {
        ArrayList<Person> list2 = new ArrayList<>();
//        list2.add("a");
        list2.add(new Person("张三", 23));
        list2.add(new Person("李四", 24));
        list2.add(new Person("王五", 25));
        list2.add(new Person("赵六", 26));

        Iterator<Person> it2 = list2.iterator();
        while (it2.hasNext()) {
            Person p = it2.next();

            System.out.println(p);
        }
    }

    private static void demo1() {
        ArrayList<String> list1 = new ArrayList<>();
        list1.add("a");
        list1.add("b");
        list1.add("c");
        list1.add("d");
//        list1.add(new Person("张三", 23));

        Iterator<String> it1 = list1.iterator();
        while (it1.hasNext()) {
            String s = it1.next();

            System.out.println(s);
        }
    }
}
